package ysq.xyg.sys.model.po;

import lombok.NoArgsConstructor;

import lombok.Data;
import ysq.xyg.base.util.BaseConstant;
import ysq.xyg.base.util.BaseUtil;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.Date;

/**
 * 系统管理-角色菜单实体类
 *
 * @author shengQiang yu
 * @date 2019-4-8 8:55:21
 */
@Data
@NoArgsConstructor
@Table(name = "xyg_sys_role_menu")
public class SysRoleMenu implements Serializable{

	/**
     * 主键
     */ 
	@Id
	private String id;
	
	/**
     * 角色主键
     */ 
	@Column(name = "role_id")
	private String roleId;
	
	/**
     * 菜单主键
     */ 
	@Column(name = "menu_id")
	private String menuId;
	
	/**
     * 删除标注:1、正常，2、删除
     */ 
	@Column(name = "remove_tag")
	private String removeTag;
	
	/**
     * 创建时间
     */ 
	@Column(name = "create_time")
	private Date createTime;
	
	/**
     * 创建人
     */ 
	@Column(name = "create_user")
	private String createUser;
	
	/**
     * 修改时间
     */ 
	@Column(name = "update_time")
	private Date updateTime;
	
	/**
     * 修改人
     */ 
	@Column(name = "update_user")
	private String updateUser;

	/**
	 * 角色名称
	 */
	@Transient
	private String roleName;

	/**
	 * 菜单名称
	 */
	@Transient
	private String menuName;

	/**
	 * 图标
	 */
	@Transient
	private String menuIcon;

	/**
	 * 父级id
	 */
	@Transient
	private String parentId;

	/**
	 * 菜单连接
	 */
	@Transient
	private String menuUrl;

	public SysRoleMenu(SysUser sysUser) {
		this.id= BaseUtil.uId();
		this.removeTag= BaseConstant.BASE_REMOVE_TAG_NORMAL;
		this.createTime = new Date();
		this.createUser = sysUser.getId();
		this.updateTime = new Date();
		this.updateUser = sysUser.getId();
	}
	public SysRoleMenu(SysUser sysUser,String roleId,String menuId) {
		this.id= BaseUtil.uId();
		this.roleId=roleId;
		this.menuId=menuId;
		this.removeTag= BaseConstant.BASE_REMOVE_TAG_NORMAL;
		this.createTime = new Date();
		this.createUser = sysUser.getId();
		this.updateTime = new Date();
		this.updateUser = sysUser.getId();
	}

	public SysRoleMenu(String roleId) {
		this.roleId = roleId;
	}
}